package com.lancoo.answer.widget.subject

import android.graphics.Color
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.lancoo.answer.R

abstract class SubjectSelectAdapter<T> constructor( var currentSelect:Int = 0): BaseQuickAdapter<T, BaseViewHolder>(R.layout.ev_item_layout_subject_select) {

    @JvmName("setCurrentSelect1")
    fun setCurrentSelect(currentSelect: Int){
        this.currentSelect = currentSelect
        notifyDataSetChanged()
    }


    override fun convert(holder: BaseViewHolder, item: T) {

        val  tv_subject  = holder.getView<TextView>(R.id.tv_subject)
        if (currentSelect == getItemPosition(item)) {
            //设置选中背景
            tv_subject.setTextColor(Color.parseColor("#169cff"))
        } else {
            //设置没选中背景
            tv_subject.setTextColor(Color.parseColor("#282828"))
        }
        convert(tv_subject,item)
    }

    abstract fun convert(selectItem:TextView,item: T)
}